<template>
  <div>
    <ul>
      <li v-for="(item, index) in list" :key="item.userId">
        <div class="img">
          <img width="50" height="50" :src="item.backgroundUrl" alt="" />
          <span class="msk"></span>
          <div class="user">
            <span style="color: #0c73c2">{{ item.nickname }}</span>
            <span style="color: #999">{{ item.signature }}</span>
          </div>
          <i></i>
        </div>
        <!-- right  -->
        <div class="right">
          <div class="icon">关注</div>
          <span> 歌单：{{item.playlistCount}} </span>
          <span>粉丝：{{item.followeds}}</span>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'user',
  data() {
    return {
      list: [], //列表
      userprofileCount: '', //用户总数
    }
  },
  methods: {
    async getuser() {
      const { data: res } = await this.$http.get(
        `/cloudsearch?keywords=${this.searchName}&type=1002`
      )
      if (res.code !== 200) this.$message.error('搜索失败')
      this.userprofileCount = res.result.userprofileCount //用户总数
      this.list = res.result.userprofiles // 数据；列表
    },
  },

  created() {
    this.$store.commit('search/getsearchlist', this.$route.meta.title)
    this.getuser()
  },
  computed: {
    ...mapState('search', ['searchName']),
  },
}
</script> 

<style scoped lang="less">
ul {
  margin-top: 20px;
}
// 图标背景
.msk {
  position: absolute;
  top: 7px;
  left: 0;
  width: 100%;
  height: 100%;
  background: url(../../../assets/images/coverall.png) no-repeat -160px 0;
  cursor: pointer;
  width: 50px;
  height: 50px;
}
ul li {
  height: 62px;
  border: 1px solid white;
  display: flex;
  justify-content: space-between;
  .img {
    display: flex;
    align-items: center;
    position: relative;
    .user {
      display: flex;
      flex-direction: column;
      width: 470px;
      margin-left: 10px;
      font-size: 12px;
      span {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
  .right {
    display: flex;
  }
}

// 右边部分
.right {
  width: 100%;
  display: flex;
  align-items: center;
  .icon {
    width: 64px;
    height: 27px;
    background: url(../../../assets/images/button.png) 0 -990px;
    display: flex;
    color: #5d5d5d;
    align-items: center;
    font-size: 12px;
    text-indent: 1rem;
    cursor: pointer;
    justify-content: center;
    margin: 30px;
  }
    span {
      color: #999;
      font-size: 12px;
      text-align: left;
      flex: 1;
    }
}
li:nth-child(even) {
  background: #f7f7f7;
  // 关注样式
}
</style>